﻿using B.S.BasicData.Domain.SystemUsers;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Infrastructure.Interfaces;
using B.S.BasicData.Write.Api.Application.Command.SystemUsers.IAMCommand;
using MediatR;

namespace B.S.BasicData.Write.Api.Application.CommandHandler.SystemUsers.IAMCommand
{
    /// <summary>
    /// 身份验证获取
    /// </summary>
    public class IAMGetCommandHandler:IRequestHandler<IAMGetCommand,ApiResult<IAM_Model>>
    {
        private readonly IBaseRepository<IAM_Model> _baseRepository;

        public IAMGetCommandHandler(IBaseRepository<IAM_Model> baseRepository)
        {
            _baseRepository = baseRepository;
        }

        public Task<ApiResult<IAM_Model>> Handle(IAMGetCommand request, CancellationToken cancellationToken)
        {
            var res=new ApiResult<IAM_Model>();
            var iam = _baseRepository.GetById(request.Id);
            res.Data = iam;
            res.Msg = "获取成功";
            res.Code = ApiEnums.Success;
            return Task.FromResult(res);
        }
    }
}
